package com.ww.java8.fp.lambda;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import com.alibaba.fastjson2.JSON;

import cn.hutool.core.date.DateUtil;

public class SortedDemo01 {

	public static void main(String[] args) {
//		List<Person> personList = new ArrayList<>();
//		personList.add(new Person("张三", 20));
//		personList.add(new Person("李四", 10));
//		personList.add(new Person("王五", 25));
//		personList.add(new Person("赵六", 12));
//		personList.add(new Person("田七", 30));
//		
//		List<Person> sortedPerson = personList.stream().sorted(Comparator.comparing(Person::getAge)).collect(Collectors.toList());
//		System.out.println(JSON.toJSONString(sortedPerson));
//		
//		Animal animal = new Animal();
//		animal.setPersonList(personList);
//		
//		List<Person> sortedPerson2 = animal.getPersonList().stream().sorted(Comparator.comparing(Person::getAge)).collect(Collectors.toList());
//		System.out.println(JSON.toJSONString(sortedPerson2));
//		
		Date todayBeginTime = DateUtil.beginOfDay(new Date());
		Date endTime = DateUtil.parse("2023-08-20", "yyyy-MM-dd");
		
		long betweenDay = DateUtil.betweenDay(endTime, todayBeginTime, false);
		System.out.println(betweenDay);
	}
}

class Animal {
	
	private String classify;
	
	private List<Person> personList;

	public String getClassify() {
		return classify;
	}

	public void setClassify(String classify) {
		this.classify = classify;
	}

	public List<Person> getPersonList() {
		return personList;
	}

	public void setPersonList(List<Person> personList) {
		this.personList = personList;
	}
}

class Person {
	
	private String name;
	
	private Integer age;
	
	public Person() {}
	
	public Person(String name, Integer age) {
		this.name = name;
		this.age = age;
	}
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	@Override
	public String toString() {
		return "Person [name=" + name + ", age=" + age + "]";
	}
}